const sequelize = require("./db");
const { DataTypes } = require("sequelize");
const Product = require("./Product");

//创建一个模型对象
const Product_picture = sequelize.define(
  "Product_picture",
  {
    id: {
      type: DataTypes.INTEGER,
      autoIncrement: true,
      primaryKey: true,
    },
    product_id: {
      type: DataTypes.INTEGER,
      allowNull: false,
      references: {
        // 这是对另一个模型的参考
        model: Product,
        // 这是引用模型的列名
        key: "product_id",
      },
    },
    product_picture: {
      type: DataTypes.STRING(200),
    },
    intro: {
      type: DataTypes.TEXT,
    },
  },
  {
    timestamps: false
  }
);
module.exports = Product_picture;
